Skip to content

[FIX] Guard .first() queries against None to prevent AttributeError#1070

Open
DhanushVarma-2 wants to merge 2 commits intoCCExtractor:masterfrom
DhanushVarma-2:fix/none-dereference-on-empty-queries
Open

[FIX] Guard .first() queries against None to prevent AttributeError#1070
DhanushVarma-2 wants to merge 2 commits intoCCExtractor:masterfrom
DhanushVarma-2:fix/none-dereference-on-empty-queries

Conversation

@DhanushVarma-2
Copy link

@DhanushVarma-2 DhanushVarma-2 commented Mar 20, 2026

Three queries called .first().value or .first().commit without checking
for None. On a fresh install or empty database, these crash with
AttributeError.

Fixed:

  • mod_ci/controllers.py: GeneralData query for fetch_commit_{platform}.
    Downstream query for last_commit skipped when commit_hash is None
    to avoid WHERE commit IS NULL.
  • mod_home/controllers.py: GeneralData query for last_commit on homepage.
    Template receives None which Jinja2 renders gracefully.
  • mod_sample/controllers.py: GeneralData and CCExtractorVersion queries.
    Downstream Test queries skipped when values are None.

@DhanushVarma-2 DhanushVarma-2 force-pushed the fix/none-dereference-on-empty-queries branch 3 times, most recently from 351ecd3 to b7db2b8 Compare March 21, 2026 06:41
Three queries called .first().value or .first().commit without
checking for None. On a fresh install or empty database, these
crash with AttributeError.

Fixed in mod_ci/controllers.py, mod_home/controllers.py, and
mod_sample/controllers.py.
@DhanushVarma-2 DhanushVarma-2 force-pushed the fix/none-dereference-on-empty-queries branch from b7db2b8 to c88f2a1 Compare March 21, 2026 06:49
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant